{template 'common/header'}
<ul class="nav nav-tabs">
    <li {if $op=='list' } class="active" {/if}>
        <a href="{php echo $this->createWebUrl('movieorder', array('op' => 'list'));}">电影票订单列表</a>
    </li>
	{if $op=='post' }
	<li class="active">
        <a href="#">电影票订单详情</a>
    </li>
	{/if}
</ul>
{if $op=='list'}
<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{php echo $this->modulename}" />
				<input type="hidden" name="do" value="movieorder" />
				

				<div class="form-group">
					<label class="col-xs-12 col-sm-1 control-label">订单号搜索</label>
					<div class="col-sm-2 col-xs-12">
						<input class="form-control" name="keyword2" id="" type="text" value="{$_GPC['keyword2']}" placeholder="根据订单号搜索">
					</div>
					<div class="col-sm-2 col-xs-12">
                        <select name="keyword1" class="form-control">
						    <option value="" >全部</option>
                            <option value="2" >已付款受理中</option>
							 <option value="3" >待出票</option>
                            <option value="4" >已出票</option>
							<option value="5" >已结算</option>
							<option value="10" >已关闭</option>
                        </select>
                    </div>
					<div class="col-sm-5">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<button type="button" class="btn btn-default">总记录数：{$total}</button>
					</div>
				</div>
			</form>
		</div>
</div>

<form action="" class="form-horizontal form" method="post" enctype="multipart/form-data">
    <div style="padding:15px;">
        <table class="table table-hover table-condensed">
            <thead class="navbar-inner">
                <tr>
                    <tr>

                    <th>id</th>

                    <th>状态</th>

					<th>用户</th>

					<th>订单号</th>

					<th>影院</th>

					<th>影片名</th>

					<th>座位</th>

					<th>底价折扣</th>

					 <th>订单金额</th>

					 <th>出票价格</th>

					 <th>订单佣金</th>

                    <th>付款时间</th>

					<th style="text-align:right;">操作</th>

                </tr>
            </thead>
                <tbody id="level-list">

                {loop $list $item}
                <tr>

                    <td>{$item['id']}</td>

					<td>{if $item['orderStatus'] == 2}已付款{/if}{if $item['orderStatus'] == 3}待出票{/if}{if $item['orderStatus'] == 4}已出票{/if}{if $item['orderStatus'] == 5}已结算{/if}{if $item['orderStatus'] == 10 || $item['orderStatus'] == 0}已关闭{/if}</td>

					<td>
					<?php
					   $user = array();
					   if($settings['system_type'] == 1){
				           $user = pdo_get($this->modulename . "_user_u", array("user_id" => $item['user_id']));
					   }else{
					       $user = pdo_get($this->modulename . "_user", array("user_id" => $item['user_id']));
					   }
				    ?>

                        <img style="width: 40px;" src="{$user['avatar']}">

                        {$user['nickname']}

                    </td>

					<td>{php echo explode("_",$item['thirdOrderId'])[2]}</td>

					<td>{$item['cinemaName']}</td>

					<td>{$item['filmName']}</td>

					<td>{$item['seat']}</td>

					<td>{php echo 100*$item['downDiscountRate'];}/{php echo 100*$item['upDiscountRate'];}</td>

					<td>￥{php echo round($item['orderPrice']/100,2);}</td>

					<td>￥{php echo round($item['realorderPrice']/100,2);}</td>

					<td>￥{if $item['realorderPrice']}{php echo round(($item['orderPrice'] - $item['realorderPrice'])/100,2)}{else}0{/if}</td>
					<td><div class="type-parent">{if $item['pay_time']}{php echo date('Y-m-d H:i:s',$item['pay_time'])}{/if}</div></td>

					<td style="text-align:right;width: 30%;">
					    {if $settings['movie_api_s_appKey'] == '10000000000'}
                        <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'WAIT_TICKET','id'=>$item['id']))}" onclick="return confirm('确认将订单状态改为已受理？');return false;" title="已受理">已受理</a>

						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'TICKET_SUCCESS','id'=>$item['id']))}" onclick="return confirm('确认将订单状态改为已出票？');return false;" title="已出票">已出票</a>

						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'TICKET_SYNC','id'=>$item['id']))}" onclick="return confirm('确认将订单状态改为重新出票？');return false;" title="程序出票">重新出票</a>

						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'ORDER_FINISH','id'=>$item['id']))}" onclick="return confirm('确认将订单状态改为已结算？');return false;" title="已结算">已结算</a>

						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'ORDER_CLOSE','id'=>$item['id']))}" onclick="return confirm('确认将订单状态改为已关闭并退款？');return false;" title="已关闭并退款">关闭并退款</a>
						{else}
						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'post','id'=>$item['id']))}" title="详情">详情{if $settings['movie_ticket_type'] == 1}/手动出票{/if}</a>

						{if $settings['movie_ticket_type'] == 1}

						<!--<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'ticketer','id'=>$item['id']))}" onclick="return confirm('确认将订单推送给票商报价？');return false;" title="通知票商报价">通知票商报价</a>

						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'view_price','id'=>$item['id']))}" title="查看票商报价">查看票商报价</a>-->

						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'third','id'=>$item['id']))}" onclick="return confirm('请确保第三方余额充足，否则将会关闭订单退款给用户(停售时间：{$item['stopSellTime']})');return false;" title="将订单发送给第三方出票">第三方出票(停售时间：{$item['stopSellTime']})</a>
						{/if}

						<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('movieorder',array('op'=>'refound','id'=>$item['id']))}" onclick="return confirm('确认将订单关闭并退款？');return false;" title="已关闭并退款">关闭并退款</a>
						{/if}

						<a class="btn btn-default btn-sm"   href="{php echo $this->createWebUrl('movieorder',array('op'=>del,'id'=>$item['id']))}" onclick="return confirm('确认删除此用户吗？');return false;" title="删除">删除</a>


                    </td>


                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
    </div>
</form>
{elseif $op=='post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="{$movieorder['id']}" />
		<div class="panel panel-default">
			<div class="panel-heading">
				电影票订单信息
			</div>
			<div class="panel-body">
			    <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="{$movieorder['thirdOrderId']}" disabled="disabled" />
					</div>
				</div>
			    <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">影院信息</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="【{$movieorder['cinemaName']}】{$movieorder['cinemaAddress']}" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">座位信息</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="{$movieorder['seat']}" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">票价信息</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="【市场价：￥{php echo round($movieorder['initPrice']/100,2);}】【付款金额：￥{php echo round($movieorder['orderPrice']/100,2);}】【付款时间：{php echo date('Y-m-d H:i:s',$movieorder['pay_time']);}】" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">用户手机号</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[reservedPhone]" class="form-control" value="{$movieorder['reservedPhone']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label" style="font-weight:bold;">核对订单信息</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" class="form-control" value="【影片名：{$movieorder['filmName']}】【影院：{$movieorder['cinemaName']}】【影厅：{$movieorder['hallName']}】【放映时间：{$movieorder['showTime']}】【座位：{$movieorder['seat']}】" disabled="disabled" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red;font-weight:bold;">出票价格</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[realorderPrice]" class="form-control" style="color:red;" value="{php echo round($movieorder['realorderPrice']/100,2);}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red;font-weight:bold;">出票座位</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[realSeat]" style="color:red;" class="form-control" value="{$movieorder['realSeat']}" />
						<span class="help-block">多个座位请用英文逗号,分隔</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red;font-weight:bold;">取票码</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[ticketCode]" class="form-control" style="color:red;" value="{$ticketCode}" />
						<span class="help-block">多个取票码请用英文逗号,分隔</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red;font-weight:bold;">取票码截图</label>
					<div class="col-sm-9">
						{php echo tpl_form_field_multi_image('ticketImage', $ticketImage, array());}
						<span class="help-block" style="color:#f00">上传取票码截图，支持多张图片。</span>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
{/if}
{template 'common/footer'}
